<?php

use Faker\Factory as Faker;
use App\Models\GoodsEvaluate;
use App\Repositories\GoodsEvaluateRepository;

trait MakeGoodsEvaluateTrait
{
    /**
     * Create fake instance of GoodsEvaluate and save it in database
     *
     * @param array $goodsEvaluateFields
     * @return GoodsEvaluate
     */
    public function makeGoodsEvaluate($goodsEvaluateFields = [])
    {
        /** @var GoodsEvaluateRepository $goodsEvaluateRepo */
        $goodsEvaluateRepo = App::make(GoodsEvaluateRepository::class);
        $theme = $this->fakeGoodsEvaluateData($goodsEvaluateFields);
        return $goodsEvaluateRepo->create($theme);
    }

    /**
     * Get fake instance of GoodsEvaluate
     *
     * @param array $goodsEvaluateFields
     * @return GoodsEvaluate
     */
    public function fakeGoodsEvaluate($goodsEvaluateFields = [])
    {
        return new GoodsEvaluate($this->fakeGoodsEvaluateData($goodsEvaluateFields));
    }

    /**
     * Get fake data of GoodsEvaluate
     *
     * @param array $postFields
     * @return array
     */
    public function fakeGoodsEvaluateData($goodsEvaluateFields = [])
    {
        $fake = Faker::create();

        return array_merge([
            'order_id' => $fake->randomDigitNotNull,
            'goods_id' => $fake->randomDigitNotNull,
            'attribute_id' => $fake->randomDigitNotNull,
            'level' => $fake->randomDigitNotNull,
            'content' => $fake->text,
            'user_id' => $fake->randomDigitNotNull,
            'reply' => $fake->text,
            '>pictures' => $fake->text,
            'is_anonym' => $fake->randomDigitNotNull,
            'created_at' => $fake->word,
            'updated_at' => $fake->word
        ], $goodsEvaluateFields);
    }
}
